<template>
  <div>

    <Modal v-model="noticeFlage" :title="noticesDetail.title">
      <div v-if="noticesDetail" class="noticesDetail" v-html="noticesDetail.content">

      </div>
    </Modal>
    <div class="top" style="height: 80px; background-color: #457bec"  >

    </div>
    <div class="box flex">
      <div class="box-left">
        <div class="card shop flex" v-for="(item, index) in 3">
          <div>

            <img class="shop-logo" :src="userData.storeLogo || require('@/assets/logo1.png')" alt="">
          </div>
          <div class="shop-box">
            <div class="box-item">
              <div>店铺名称：{{ userData.storeName || '暂无' }}</div>
            </div>
            <div class="box-item">
              <div>店铺类型：{{ userData.storeDisable == 'OPEN' ? '开启中' : '关闭' }}</div>
            </div>
            <div class="box-item" @click="im()">
              <Button type="info"  :loading='load' @click="skipShop" style="background-color: #457bec;border-color: transparent;">进入店铺</Button>

            </div>
          </div>
        </div>
      <div  style="width: 100% ;display: flex; justify-content: center">
        <Button type="info"  style="width: 300px;height: 50px; background-color: #457bec;border-color: transparent;font-size: 16px;">创造店铺</Button>
      </div>
      </div>
    </div>
    
  </div>
</template>

<script>
import { getSellerHomeData, getHomeNotice } from "@/api/index";
import { getIMDetail } from "@/api/common"
import { seeArticle } from "@/api/pages";
import Cookies from "js-cookie";
import { userMsg } from "@/api/index";

export default {
  name: "home",
  data () {
    return {
      noticeFlage: false, // 控制平台公告显隐

      homeData: {}, // 首页数据
      userData: "", // 店铺信息
      notices: "", // 平台公告列表
      noticesDetail: { // 平台公告详情
        title: "",
      },
      IMLink: "",
      load:false, //加载Im
    };
  },

  methods: {
    // 跳转页面
    navigateTo (name) {
      this.$router.push({
        name,
      });
    },
    // 初始化数据
    async init () {
      let userInfo = JSON.parse(Cookies.get("userInfoSeller"));

      this.userData = userInfo;

      let res = await getHomeNotice();
      if (res.success) {
        this.notices = res.result.records;
      }
    },

    // 获取im信息
    async getIMDetailMethods () {
      let res = await getIMDetail();
      if (res.success) {
        this.IMLink = res.result;
      }
    },
    // 获取首页数据
    async getHomeData () {
      let res = await getSellerHomeData();
      if (res.success) {
        this.homeData = res.result;
      }
    },
    // 跳转首页
    skipShop () {
      this.$router.push("home");
    },
  },
  mounted () {
    this.init();
    this.getHomeData();
  },
};
</script>
<style lang="scss" scoped>
@import "./select.scss";
.noticesDetail{
  /deep/ img{
    max-width: 100%;
    max-height: 200px;
  }
}
</style>

